package com.rr.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.stp.StpUtil;
import cn.dev33.satoken.util.SaResult;
import com.rr.entity.Module;
import com.rr.service.ModuleService;
import com.rr.utils.core.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("module")
public class ModuleController extends  BaseController{
    @Autowired
     private ModuleService moduleService;
    @RequestMapping ("getModules")
    @SaCheckLogin
    public SaResult getModules()
    {
        String roleId = StpUtil.getRoleList().get(0);
        return success( moduleService.queryModelByRoleId(Integer.parseInt(roleId)));
    }
    @RequestMapping("getAllModules")
    @SaCheckRole("1")
    public TableDataInfo getAllModules(Module module)
    {
        startPage();
        List<Module> modules = moduleService.queryAllModule(module);
        return  getDataTable(modules);

    }

}
